package com.budwk.app.sqfwV2.generator.publicSecurity.exce;


import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONObject;
import com.budwk.app.sqfw.enums.DownLoadFileNameEnum;
import com.budwk.app.sqfw.models.Sqfw_formSummary_new;
import com.budwk.app.sqfwDoc.bo.SqfwExcelForSummaryBO;
import com.budwk.app.sqfwDoc.bo.SqfwExcelJudgeRes;
import com.budwk.app.sqfwDoc.codeGenerator.excelGenerate.BaseTemplateExcelGenerator;
import com.budwk.app.sqfwDoc.codeGenerator.excelGenerate.SqfwExcelCreateCommonBO;
import com.budwk.app.sqfwV2.dto.image.PublicSecurityExcelImageConfigBO;
import com.budwk.app.sqfwV2.dto.publicSecurity.PublicSecurityDTO;
import com.budwk.app.util.poiUtils.CommonFormOfficeUtils;
import com.budwk.app.util.poiUtils.excelPictureConfigBO.ExcelFileCreateParamBO;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author 东方祥云低代码1.1
 * @since 2024-03-25
 * <p>
 * 大营路社会治安 1
 * 【社会治安重点风险场所】台账.xlsx
 */
public class PublicSecurityExcelGenerator extends BaseTemplateExcelGenerator {

    private final String template;

    public PublicSecurityExcelGenerator(String template) {
        this.template = template;
    }

    @Override
    protected void customerPopularSheetBaseParam(Map<String, Object> excelParam, SqfwExcelCreateCommonBO excelCreateParam) {

    }

    @Override
    protected void customerPopularSheetDataParam(List<Map<String, Object>> listMap, SqfwExcelCreateCommonBO excelCreateParam) {

    }

    @Override
    protected String getTemplateName() {
        //return PublicSecurityFileEnum.PUBLIC_SECURITY_STANDING_BOOK.getTemplatePath();
        return template;
    }

    @Override
    public String getDownloadFileName() {
        return DownLoadFileNameEnum.DYL_PUBLIC_SECURITY_STANDING_BOOK.getName() + "_" + DateUtil.format(new Date(), "yyyyMMddHHmmss");
    }

    /**
     * 允许用户在创建excel文件之前对配置进行修改
     *
     * @param excelFileCreateParamBO 创建excel的配置参数
     */
    @Override
    protected void completeExcelFileCreateParam(ExcelFileCreateParamBO excelFileCreateParamBO) {

    }

    @Override
    protected void customerPopularRowDataMap(Map<String, Object> rowDataMap, SqfwExcelForSummaryBO forSummaryBO) {
        Sqfw_formSummary_new sqfwFormSummaryNew = forSummaryBO.getSqfwFormSummaryNew();
        PublicSecurityDTO publicSecurityDTO = JSONObject.parseObject(sqfwFormSummaryNew.getParamData(), PublicSecurityDTO.class);
        //MainBusinessScopeDTO mainBusinessScopeDTO = publicSecurityDTO.getMainBusinessScope();
        rowDataMap.put("InCrimeAndEvil", "true".equals(rowDataMap.get("InCrimeAndEvil").toString()) ? "有" : "无");
        rowDataMap.put("whetherThereIsAnyHiddenDanger", "true".equals(rowDataMap.get("whetherThereIsAnyHiddenDanger").toString()) ? "有" : "无");
        //rowDataMap.put("mainBusinessScope", mainBusinessScopeDTO.getKey());
        rowDataMap.put("checkedUnitLeader", CommonFormOfficeUtils.addPictureToByteList(publicSecurityDTO.getCheckedUnitLeader(), 1));
        rowDataMap.put("visitPictures", CommonFormOfficeUtils.addPictureToByteList(publicSecurityDTO.getVisitPictures(), 5));


    }

    @Override
    protected SqfwExcelJudgeRes judgeDataIntoExcelBeforeErgodic(SqfwExcelCreateCommonBO excelCreateParam, Map<String, Object> excelParam) {
        return null;
    }

    @Override
    protected SqfwExcelJudgeRes judgeDataIntoExcelBeforeCreate(Map<String, Object> excelParam) {
        return null;
    }

    @Override
    protected Class<?> getImageConfigBO() {
        return PublicSecurityExcelImageConfigBO.class;
    }
}
